package b.r;

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import androidx.transition.Transition;
import androidx.transition.TransitionSet;
import b.i.k.o;
import b.l.a.z;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.WeakHashMap;

@SuppressLint({"RestrictedApi"})
/* compiled from: FragmentTransitionSupport */
public class a extends z {

    /* compiled from: FragmentTransitionSupport */
    public class a extends androidx.transition.Transition.c {
        public a(a aVar, Rect rect) {
        }
    }

    /* compiled from: FragmentTransitionSupport */
    public class b implements androidx.transition.Transition.d {
        public final /* synthetic */ View a;
        public final /* synthetic */ ArrayList b;

        public b(a aVar, View view, ArrayList arrayList) {
            this.a = view;
            this.b = arrayList;
        }

        public void a(Transition transition) {
        }

        public void b(Transition transition) {
        }

        public void c(Transition transition) {
        }

        public void d(Transition transition) {
        }

        public void e(Transition transition) {
            transition.w(this);
            this.a.setVisibility(8);
            int size = this.b.size();
            for (int i = 0; i < size; i++) {
                ((View) this.b.get(i)).setVisibility(0);
            }
        }
    }

    /* compiled from: FragmentTransitionSupport */
    public class d extends androidx.transition.Transition.c {
        public d(a aVar, Rect rect) {
        }
    }

    /* compiled from: FragmentTransitionSupport */
    public class c extends f {
        public final /* synthetic */ Object a;
        public final /* synthetic */ ArrayList b;
        public final /* synthetic */ Object c;
        public final /* synthetic */ ArrayList d;
        public final /* synthetic */ Object e;
        public final /* synthetic */ ArrayList f;

        public c(Object obj, ArrayList arrayList, Object obj2, ArrayList arrayList2, Object obj3, ArrayList arrayList3) {
            this.a = obj;
            this.b = arrayList;
            this.c = obj2;
            this.d = arrayList2;
            this.e = obj3;
            this.f = arrayList3;
        }

        public void a(Transition transition) {
            Object obj = this.a;
            if (obj != null) {
                a.this.n(obj, this.b, null);
            }
            obj = this.c;
            if (obj != null) {
                a.this.n(obj, this.d, null);
            }
            obj = this.e;
            if (obj != null) {
                a.this.n(obj, this.f, null);
            }
        }

        public void e(Transition transition) {
            transition.w(this);
        }
    }

    public static boolean v(Transition transition) {
        return (z.k(transition.e) && z.k(null) && z.k(null)) ? false : true;
    }

    public void a(Object obj, View view) {
        if (obj != null) {
            ((Transition) obj).b(view);
        }
    }

    public void b(Object obj, ArrayList<View> arrayList) {
        Transition transition = (Transition) obj;
        if (transition != null) {
            int i = 0;
            int size;
            if (transition instanceof TransitionSet) {
                TransitionSet transitionSet = (TransitionSet) transition;
                size = transitionSet.x.size();
                while (i < size) {
                    b(transitionSet.J(i), arrayList);
                    i++;
                }
            } else if (!v(transition) && z.k(transition.f)) {
                size = arrayList.size();
                while (i < size) {
                    transition.b((View) arrayList.get(i));
                    i++;
                }
            }
        }
    }

    public void c(ViewGroup viewGroup, Object obj) {
        Transition transition = (Transition) obj;
        if (!g.c.contains(viewGroup)) {
            WeakHashMap weakHashMap = o.a;
            if (viewGroup.isLaidOut()) {
                g.c.add(viewGroup);
                transition = transition.clone();
                ArrayList arrayList = (ArrayList) g.a().getOrDefault(viewGroup, null);
                if (arrayList != null && arrayList.size() > 0) {
                    Iterator it = arrayList.iterator();
                    while (it.hasNext()) {
                        ((Transition) it.next()).v(viewGroup);
                    }
                }
                if (transition != null) {
                    transition.h(viewGroup, true);
                }
                if (((c) viewGroup.getTag(2131297071)) == null) {
                    viewGroup.setTag(2131297071, null);
                    if (transition != null) {
                        b.r.g.a aVar = new b.r.g.a(transition, viewGroup);
                        viewGroup.addOnAttachStateChangeListener(aVar);
                        viewGroup.getViewTreeObserver().addOnPreDrawListener(aVar);
                        return;
                    }
                    return;
                }
                throw null;
            }
        }
    }

    public boolean e(Object obj) {
        return obj instanceof Transition;
    }

    public Object g(Object obj) {
        return obj != null ? ((Transition) obj).clone() : null;
    }

    public Object l(Object obj, Object obj2, Object obj3) {
        TransitionSet transitionSet = new TransitionSet();
        if (obj != null) {
            transitionSet.I((Transition) obj);
        }
        if (obj2 != null) {
            transitionSet.I((Transition) obj2);
        }
        if (obj3 != null) {
            transitionSet.I((Transition) obj3);
        }
        return transitionSet;
    }

    public void m(Object obj, View view) {
        if (obj != null) {
            ((Transition) obj).x(view);
        }
    }

    public void n(Object obj, ArrayList<View> arrayList, ArrayList<View> arrayList2) {
        Transition transition = (Transition) obj;
        int i = 0;
        int size;
        if (transition instanceof TransitionSet) {
            TransitionSet transitionSet = (TransitionSet) transition;
            size = transitionSet.x.size();
            while (i < size) {
                n(transitionSet.J(i), arrayList, arrayList2);
                i++;
            }
        } else if (!v(transition)) {
            ArrayList arrayList3 = transition.f;
            if (arrayList3.size() == arrayList.size() && arrayList3.containsAll(arrayList)) {
                if (arrayList2 == null) {
                    size = 0;
                } else {
                    size = arrayList2.size();
                }
                while (i < size) {
                    transition.b((View) arrayList2.get(i));
                    i++;
                }
                int size2 = arrayList.size();
                while (true) {
                    size2--;
                    if (size2 >= 0) {
                        transition.x((View) arrayList.get(size2));
                    } else {
                        return;
                    }
                }
            }
        }
    }

    public void o(Object obj, View view, ArrayList<View> arrayList) {
        ((Transition) obj).a(new b(this, view, arrayList));
    }

    public void p(Object obj, Object obj2, ArrayList<View> arrayList, Object obj3, ArrayList<View> arrayList2, Object obj4, ArrayList<View> arrayList3) {
        ((Transition) obj).a(new c(obj2, arrayList, obj3, arrayList2, obj4, arrayList3));
    }

    public void q(Object obj, Rect rect) {
        if (obj != null) {
            ((Transition) obj).B(new d(this, rect));
        }
    }

    public void r(Object obj, View view) {
        if (view != null) {
            Transition transition = (Transition) obj;
            Rect rect = new Rect();
            j(view, rect);
            transition.B(new a(this, rect));
        }
    }

    public void s(Object obj, View view, ArrayList<View> arrayList) {
        TransitionSet transitionSet = (TransitionSet) obj;
        ArrayList arrayList2 = transitionSet.f;
        arrayList2.clear();
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            z.d(arrayList2, (View) arrayList.get(i));
        }
        arrayList2.add(view);
        arrayList.add(view);
        b(transitionSet, arrayList);
    }

    public void t(Object obj, ArrayList<View> arrayList, ArrayList<View> arrayList2) {
        TransitionSet transitionSet = (TransitionSet) obj;
        if (transitionSet != null) {
            transitionSet.f.clear();
            transitionSet.f.addAll(arrayList2);
            n(transitionSet, arrayList, arrayList2);
        }
    }

    public Object u(Object obj) {
        if (obj == null) {
            return null;
        }
        TransitionSet transitionSet = new TransitionSet();
        transitionSet.I((Transition) obj);
        return transitionSet;
    }
}
